package com.njbdqn.updown.service;

import com.njbdqn.updown.dao.IStudentDAO;
import com.njbdqn.updown.vo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class StuService {
    @Autowired
    private IStudentDAO studao;
    public synchronized String getNewName(String oldName){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddhhmmss");
        return sdf.format(new Date())+oldName.substring(oldName.indexOf("."));
    }
    public void save(Student stu){
        studao.saveStu(stu);
    }
    public List<Student> findAll(){
        return studao.findAll();
    }
}
